#pragma once
#include <string>

namespace krryn{
namespace core{
	template<typename _Ty> 
	class refc_ptr;

	class job{
	public:
		typedef refc_ptr<job> ptr;

		virtual std::string get_name();
		virtual void execute() = 0;
		virtual void done() {};
	};

	class job_manager;
	class job_group{
	public:
		typedef refc_ptr<job_group> ptr;

		job_group();
		~job_group();

		void add(job::ptr a_Job);
		void add_to(job_manager &a_Manager);

		void depends_on_all_of(job_group::ptr a_Group);
		void depends_on_any_of(size_t a_Amount, job_group::ptr a_Group);
	private:
		class group_job;
		class impl;
		impl *m_Pimpl;
	};

	class job_manager{
	public:
		typedef refc_ptr<job_manager> ptr;

		explicit job_manager(size_t a_NumberOfThreads);

		~job_manager();

		void add(job_group::ptr a_Group);
		void add(job::ptr a_Job);
		job::ptr next();
	private:
		class job_thread;
		class impl;
		impl *m_Pimpl;
	};
}
}
